function main()
% search for rectangle copy-scale-move in the following steps
% 1. search for all horizontal and vertical edges
% 1.1 find vertical edges in 3 color space
% 1.2 merge (or) values and sum in horizontal
% 1.3 choose values > threshold (total > B, at least one connected)
% 1.4 same for horizontal edges
% 2.1 find all pairs in horizontal N/2 > distance > B ,
% 2.2 find all pairs in vertical M/2 > distance > B
% for each pair 
% 2.3 form rectangle (| | - -) B*B extract features
% 2.3.1: SIFT
% 2.3.2: color in 4 corners
% 2.3.3: ?
% 3 find proper matches
% 3.1 search area for similar colors (filter)
% 3.2 search area for same SIFT (sort by feature)
% 3.3 check area if size > B*B
% 3.4 output matches, and set matched area to BLACK
% 3.5 group similar match if more than one is found
% 4 draw a clear graph, and rectangle around each match
end

function searchall(img, B)
if nargin < 2
    B = 32; % assume minimal copyed size is 32x32
end
[M,N] = size(img)
for sx = 1:N - B % M
    for sy = 1:M - B % N
        for ph = B:M - sx
            for pw = B:N - sy
                area1 = img(sy:sy+ph, sx:sx+pw);
                for tx = 1:N - B
                    for ty =1:M - B
                        for qh = B:M - tx
                            for qw = B:N - ty
                                area2 = img(ty:ty+qh, tx:tx+qw);
                            end
                        end
                    end
                end
            end
        end
    end
end

end
